package com.tcm.portal.web.controller;

import com.base.core.pager.PageBean;
import com.base.core.utils.R;
import com.tcm.invite.domain.dto.InviteRecordDTO;
import com.tcm.invite.service.InviteRecordService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RequestMapping("/invite")
@RestController
public class InviteRecordController {

    @DubboReference(version = "0.0.1-alpha", timeout = 3000, check = false, retries = 3)
    private InviteRecordService inviteRecordService;

    /**
     * 查询我的邀请记录
     * @param cellphone
     * @param spreadType
     * @param page
     * @param pagesize
     * @return
     */
    @GetMapping("/record/page")
    public R queryInviteRecordPage(String cellphone, String spreadType,Long page,Long pagesize){
        PageBean<InviteRecordDTO> inviteRecordPageBean = inviteRecordService.queryInviteRecordPage(cellphone,
                spreadType,page,pagesize);
        return R.success(inviteRecordPageBean);
    }

    /**
     * 查询我的邀请
     * @param cellphone
     * @param spreadType
     * @return
     */
    @GetMapping("/query/my/inviter")
    public R queryMyInviter(String cellphone, String spreadType){
        try{
            List<InviteRecordDTO> inviteRecordDTOList = inviteRecordService.queryInviterByPhone(cellphone,spreadType);
            return R.success(inviteRecordDTOList);
        }catch (Exception ex){
            return R.fail("出了点状况了");
        }
    }



}
